* -----------------------------------------------------------
* Date: July 22, 2021
* Purpose: Generates summary statistics of compliance.
* Output: stats_compliance_1.tex and stats_compliance_2.tex, 
* 		  stats_messages1.tex, stats_messages2.tex,
*		  compliance_cross_1.tex, compliance_cross_2.tex,
* 		  compliance_cross_3.tex, compliance_cross_4.tex

* -----------------------------------------------------------
use "${data}/oisl_clean_data.dta", clear
gen treatment_bi=treatment 
replace treatment_bi=. if treatment==0

global list1 complete complete_any complete_2 complete_3 /*
*/			 complete_4 complete_5 complete_6 complete_7 /*
*/			 complete_8 complete_9 complete_10

global list2 complete_calc complete_calc_any complete_calc_2 /*
*/			 complete_calc_3 complete_calc_4 complete_calc_5 /*
*/			 complete_calc_6 complete_calc_7 complete_calc_8 /*
*/		 	 complete_calc_9 complete_calc_10 CallDuration call_length main_pitch_length

global list3 complete_w_1 complete_w_2 complete_w_3 /*
*/			 complete_w_4 complete_w_5 complete_w_6 /*
*/			 complete_w_7 complete_w_8 complete_w_9 /*
*/			 complete_w_10

global list4 complete_calc_w_1 complete_calc_w_2 /*
*/			 complete_calc_w_3 complete_calc_w_4 /*
*/			 complete_calc_w_5 complete_calc_w_6 /*
*/			 complete_calc_w_7 complete_calc_w_8 /*
*/			 complete_calc_w_9 complete_calc_w_10

label var complete 		"Number of completed calls"
label var complete_any 	"Completed at least 1 call"
label var complete_2 	"Completed at least 2 calls"
label var complete_3 	"Completed at least 3 calls"
label var complete_4 	"Completed at least 4 calls"
label var complete_5 	"Completed at least 5 calls"
label var complete_6 	"Completed at least 6 calls"
label var complete_7 	"Completed at least 7 calls"
label var complete_8 	"Completed at least 8 calls"
label var complete_9 	"Completed at least 9 calls"
label var complete_10 	"Completed all 10 calls"

label var complete_calc 		"Number of calls in which listened to main pitch"
label var complete_calc_any 	"Listened to main pitch of at least 1 call"
label var complete_calc_2 		"Listened to main pitch of at least 2 calls"
label var complete_calc_3 		"Listened to main pitch of at least 3 calls"
label var complete_calc_4 		"Listened to main pitch of at least 4 calls"
label var complete_calc_5 		"Listened to main pitch of at least 5 calls"
label var complete_calc_6 		"Listened to main pitch of at least 6 calls"
label var complete_calc_7 		"Listened to main pitch of at least 7 calls"
label var complete_calc_8 		"Listened to main pitch of at least 8 calls"
label var complete_calc_9 		"Listened to main pitch of at least 9 calls"
label var complete_calc_10 		"Listened to main pitch of all 10 calls"
label var CallDuration "Average listening time (s)"
label var call_length "Total call length (s)"
label var main_pitch_length "Main pitch length (s)"

label var complete_w_1 	"Completed week 1"
label var complete_w_2 	"Completed week 2"
label var complete_w_3 	"Completed week 3"
label var complete_w_4 	"Completed week 4"
label var complete_w_5 	"Completed week 5"
label var complete_w_6 	"Completed week 6"
label var complete_w_7 	"Completed week 7"
label var complete_w_8 	"Completed week 8"
label var complete_w_9 	"Completed week 9"
label var complete_w_10 "Completed week 10"

label var complete_calc_w_1 	"Main Pitch week 1"
label var complete_calc_w_2 	"Main Pitch week 2"
label var complete_calc_w_3 	"Main Pitch week 3"
label var complete_calc_w_4 	"Main Pitch week 4"
label var complete_calc_w_5 	"Main Pitch week 5"
label var complete_calc_w_6 	"Main Pitch week 6"
label var complete_calc_w_7 	"Main Pitch week 7"
label var complete_calc_w_8 	"Main Pitch week 8"
label var complete_calc_w_9 	"Main Pitch week 9"
label var complete_calc_w_10 	"Main Pitch week 10"

// Compliance:
*main pitch
*eststo complc_t0: estpost summ $list2 if treatment == 0
eststo complc_t1: estpost summ $list2 if treatment == 1
eststo complc_t2: estpost summ $list2 if treatment == 2

esttab complc_*  using "${output}/stats_compliance_2.tex", replace /*
*/		main(mean %15.2fc ) label aux(sd %15.3fc) unstack /*
*/		collabels(none) noobs nonote nostar booktabs f /*
*/		mtitle("Saving IVR" "Mobile banking IVR")




// Listened to each week's message
*main pitch
*eststo complc_t0: estpost summ $list4 if treatment == 0
eststo complc_t1: estpost summ $list4 if treatment == 1
eststo complc_t2: estpost summ $list4 if treatment == 2

esttab complc_t* using "${output}/stats_messages_2.tex", replace /*
*/		main(mean %15.2fc) label aux(sd %15.3fc) unstack /*
*/		collabels(none) noobs nonote nostar booktabs f /*
*/		mtitle( "Saving IVR" "Mobile banking IVR")

